package com.kongge.algorithm.demo;


import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

import com.kongge.algorithm.tree.TreeNode;

public class TraveseTree implements IAlgorithm{

	public void execute() {
		
		List<TreeNode<Integer>> resultList;
		
		TreeNode<Integer> rootNode = TreeNode.createTree(new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9});
		
		resultList = new LinkedList<TreeNode<Integer>>();
		System.out.print("前序遍历：");
		TreeNode.preTraveseTree(rootNode, resultList);
		TreeNode.printResult(resultList);
		
		resultList = new LinkedList<TreeNode<Integer>>();
		System.out.print("\n中序遍历：");
		TreeNode.middleTraveseTree(rootNode, resultList);
		TreeNode.printResult(resultList);
		
		resultList = new LinkedList<TreeNode<Integer>>();
		System.out.print("\n后序遍历：");
		TreeNode.suffTraveseTree(rootNode, resultList);
		TreeNode.printResult(resultList);
		
		resultList = new LinkedList<TreeNode<Integer>>();
		System.out.print("\n层次遍历：");
		TreeNode.arrangementTraveseTree(rootNode, resultList);
		TreeNode.printResult(resultList);
	}
}
